{extend name="extend:iframe" /}

{block name="css"}
<link rel="stylesheet" type="text/css" href="/public/admin/css/layout.global.css" />
<style type="text/css">
	._1 img {
	    float: left;
	    width: 40px;
	    height: 40px;
	    border-radius: 30px;
	}
	._1 div {
	    float: left;
	    margin-left: 5px;
	}
	._1 div p {
	    font-size: 12px;
	    height: 20px;
	    line-height: 20px;
	}
	
	font {
	    color: #999;
	    font-size: 12px;
	}
	
	.cmd-box {
		line-height: 40px;
		position: relative;
	}
	
	.select-box {
		display: none;
		width: 100%;
		box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.08);
		padding: 0;
		margin: 0;
		list-style: none;
		background-color: #FFFFFF;
		position: absolute;
		top: 40px;
		left: 0;
	}
	
	.cmd-box:hover .select-box {
		display: block;
		z-index: 9;
	}
	
	.select-box li {
		line-height: 32px;
		border-bottom: 1px solid #EDEDED;
	}
	
	.select-box li:hover {
		background-color: #FCFCFC;
	}
	
	.select-box li a {
		font-size: 14px;
	}
</style>
{/block}


{block name="body"}
<div class="_title">
    <div class="_main">项目管理</div>
    <div class="_sub clearfix">
        <div class="_btns">
            <ul class="clearfix">
                <li class="active" layout-mark="list-model" data-model="0">全部</li>
                <li layout-mark="list-model" data-model="1">未估值</li>
                <li layout-mark="list-model" data-model="2">已估值</li>
                <li layout-mark="list-model" data-model="3">已缴纳诚信保证金</li>
                <li layout-mark="list-model" data-model="4">已删除</li>
            </ul>
        </div>
        <div class="_search clearfix">
            <input type="text" name="skey" placeholder="项目名" />
            <a href="javascript:;" layout-mark="list-skey"><i class="icon-search_-for"></i></a>
        </div>
    </div>
</div>
<div class="_content">
    <table width="100%">
        <tr>
            <th>项目</th>
            <th>融资轮次</th>
            <th>所属行业</th>
            <th>所在城市</th>
            <th>拟融资金额(万)</th>
            <th>估值</th>
            <th>诚信保证金</th>
            <th>评估报告</th>
            <th>商业计划书</th>
            <th class="text-center">操作</th>
        </tr>
        <tbody id="project-volist-view">

		</tbody>
    </table>
</div>
<div class="loadmore-modal">
	<a href="javascript:;">点击加载更多</a>
</div>
{/block}


{block name="js"}
<script type="text/html" id="project-volist-template">
	{{# for ( var i in d ) { }} 
		{{# var list = d[i]; }}
		<tr>
			<td>
				<div class="_1 clearfix">
					<img src="{{ list.logo }}" />
					<div class="">
						<p>{{ list.title }}</p>
						<p><font>{{ list.stage }}</font></p>
					</div>
				</div>
			</td>
			<td>{{ list.round }}</td>
			<td>{{ list.industry }}</td>
			<td>{{ list.city }}</td>
			<td>{{ list.money }}</td>
			<td>
				{{# if ( list.is_cx_pay == 0 ) { }}
					<i class="icon-fail" style="color:#C91723;font-size: 18px;"></i>
				{{# } else { }}
					<i class="icon-ok" style="color:#1AAD19;font-size: 18px;"></i>
				{{# } }}
			</td>
			<td>
				{{# if ( list.is_cp == 0 ) { }}
					<i class="icon-shield-unsafe" style="color:#C91723;font-size: 18px;"></i>
				{{# } else { }}
					<i class="icon-shield-safety" style="color:#1AAD19;font-size: 18px;"></i>
				{{# } }}
			</td>
			<td>
				{{# if ( list.cp_uri == '' ) { }}
					<i class="icon-files-pdf"></i>
				{{# } else { }}
					<i class="icon-files-pdf" data-uri="{{ list.cp_uri }}" style="color:#FF5300;cursor: pointer;"></i>
				{{# } }}
			</td>
			<td>
				{{# if ( list.bp == '' ) { }}
					<i class="icon-files-pdf"></i>
				{{# } else { }}
					<i class="icon-files-pdf" data-uri="{{ list.bp }}" style="color:#FF5300;cursor: pointer;"></i>
				{{# } }}
			</td>
			<td class="text-center cmd-box">
				<i class="icon-down" style="cursor: pointer;"></i>
				<ul class="select-box">
					<li>
						<a href="/project/{{ list.id }}.html" target="_blank" style="display: block;">查看</a>
					</li>
					{{# if ( list.delete_time == 0 ) { }}
					<li>
						<a href="javascript:;" style="display: block;" data-cmd="sc" data-id="{{ list.id }}" data-status="1">删除</a>
					</li>
					{{# } else { }}
					<li>
						<a href="javascript:;" style="display: block;" data-cmd="jh" data-id="{{ list.id }}" data-status="0">找回</a>
					</li>
					{{# } }}
				</ul>
			</td>
		</tr>
	{{# } }}
</script>
<script type="text/javascript" src="/public/plug/layer/layer.min.js"></script>
<script type="text/javascript" src="/public/plug/laytpl/laytpl.min.js"></script>
<script type="text/javascript" src="/public/modules/tool.js"></script>
<script type="text/javascript" src="/public/modules/interactive.js"></script>
<script type="text/javascript">
	$(function() {
		// 操作
		$('#project-volist-view').on('click', 'a[data-cmd]', function() {
			var that = $(this),
				cont = that.attr('data-cmd') == 'sc' ? '是否删除' : '是否找回',
				data_opt = {
					'project_id': that.attr('data-id'),
					'status': that.attr('data-status')
				};
			layer.open({
				type: 0,
				title: '提示',
				content: cont,
				btn: ['确定', '取消'],
				yes: function(index) {
					layer.load(0, {
						shade: [0.08, '#000']
					});
					ajax().put('/api?project.admin.audit', data_opt, function(res) {
						layer.closeAll('loading');
						if(res.status == 201) {
							window.parent.system.success('操作成功', function() {
								window.location.reload();
							});
						} else {
							window.parent.system.error(res.error);
						}
					});
					layer.close(index);
				},
				btn2: function(index) {
					layer.close(index);
				}
			});
		});
		
		// 模式
		$('li[layout-mark=list-model]').on('click', function(e) {
			$('#project-volist-view').html('');
			data_opt_volist['model'] = $(this).attr('data-model');
			data_opt_volist['page'] = 1;
			getProjectVolist();
		});
		
		// 搜索
		$('a[layout-mark=list-skey]').on('click', function(e) {
			var skey = $.trim($('input[name=skey]').val());
			$('#project-volist-view').html('');
			data_opt_volist['skey'] = skey;
			data_opt_volist['page'] = 1;
			getProjectVolist();
		});
		
		// 加载更多
		$('.loadmore-modal a').on('click', function(e) {
			var next = $(this).data('next');
			if(next > 0) {
				data_opt_volist['page'] = next;
				getProjectVolist();
			}
		});
		
		// 打开pdf
		$('#project-volist-view').on('click', '.icon-files-pdf[data-uri]', function() {
			var uri = $(this).attr('data-uri');
			if (uri) {
				tool.__cookie.set('pdf_uri', uri);
				window.open("/pdf.html");
			}
		});
	});
	
	var template = document.getElementById('project-volist-template').innerHTML,
		data_opt_volist = dataOptVolist();
	
	// 加载列表
	function getProjectVolist() {
		layer.load(0, {
			shade: [0.08, '#000']
		});
		ajax().get('/api?project.admin.volist', data_opt_volist, function(res) {
			layer.closeAll('loading');
			if(res.status >= 200 && res.status < 300) {
				$('.loadmore-modal a').data('next', res.data.next);
				if(res.data.list.length > 0) {
					// 渲染列表
					var tpl = laytpl(template);
					$('#project-volist-view').append(tpl.render(res.data.list));
					// 判断是否有分页
					if(res.data.next > res.data.page) {
						$('.loadmore-modal a').html('点击加载更多');
					} else {
						$('.loadmore-modal a').html('');
					}
				} else {
					$('.loadmore-modal a').html('暂无记录');
				}
			} else {
				window.parent.system.error(res.error);
			}
			resetIframeHeight();
		});
	}
	
	getProjectVolist();
	
	function dataOptVolist(opts) {
		return tool.optionExtend({
			'page': 1, // 当前页数
			'show': 10, // 显示条数
			'model': 0, // 模式,0-全部(默认) 1-未估值 2-已估值 3-已缴纳诚信保证金 4-已删除
			'skey': '' // 搜索关键词,项目名
		}, opts || {});
	}
</script>

{/block}